"""
doc
"""
from django.http import HttpRequest

from . import app_except


def need_login(func):
    """admin login check"""

    def d(*args, **kwargs):
        request = kwargs.get("request", None) or args[0]
        if not request.user.is_authenticated:
            raise app_except.NoAccess
        return func(*args, **kwargs)

    return d


try_and_need_login_decorators = [app_except.app_try, need_login]
